import { State } from "framework/FSM/AState";
import { ActionArgHelper } from "../../ActionManager/ActionArgHelper";
 
export class State_EnbaleRoom<T extends IStateArg<PowerCreep>>  extends State<T>
{

    public  getActions(arg:T):Action[]
    {
        const enableroom = Game.rooms[ arg.entity.memory.OwnerRoom];
        if(enableroom)
        {
            if(enableroom.controller)
            {
                if(arg.entity.pos.distance(enableroom.controller.pos)>1)
                {
                    // const motoarg:IMoveArg={creepid:"" as Id<Creep>,pos:enableroom.controller.pos,range:1,opt:{}};
                    // arg.entity.moveTo(motoarg);

                    return [ActionArgHelper.actionMoveto(arg.entity,{pos: enableroom.controller.pos,range:1},{})]
                }
                else
                {
                    arg.entity.enableRoom(enableroom.controller);
                }
            }
            else
            {
                arg.entity.log ("info",` PC任务 enableroom  挂载房间的控制器没有${arg.entity.memory.OwnerRoom}`);
            }
        }
        return [];
    }

}
